package com.atguigu.spzx.manager.service.impl;

import com.atguigu.spzx.manager.mapper.SysUserRoleMapper;
import com.atguigu.spzx.manager.service.SysUserRoleService;
import com.atguigu.spzx.model.dto.system.AssginRoleDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SysUserRoleServiceImpl implements SysUserRoleService {

    @Autowired
    private SysUserRoleMapper sysUserRoleMapper;

    /**
     * 具体实现,先删除该用户的所有角色,再根据传入进来的勾选了的角色id进行批量添加
     * @param assginRoleDto
     */
    @Override
    public void doAssign(AssginRoleDto assginRoleDto) {
        sysUserRoleMapper.deleteAllByUserId(assginRoleDto.getUserId());
        //这里需要批量操作sql
        sysUserRoleMapper.insertUserRole(assginRoleDto);
    }
}
